<%@ page import="com.tlb.ejb.*,com.tlb.dto.*,com.tlb.web.*,java.util.*" %>

<%

            Cookie[] cookies = request.getCookies();
            HashMap marks = new HashMap();
            if (cookies != null) {
                for (int c = 0; c < cookies.length; c++) {
                    if ("marks".equals(cookies[c].getName())) {
                        StringTokenizer st = new StringTokenizer(cookies[c].getValue(), ",");
                        while (st.hasMoreTokens()) {
                            marks.put(st.nextToken(), 1);
                        }
                    }
                }
            }

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>Big<%=Util.getUtil().getBoard(request) == Util.BCB ? "College" : "Law"%>Board.com</title>
        <link rel="shortcut icon" href="ext/c_sailboat.gif">
        <link rel="stylesheet" type="text/css" href="ext/tlbStyle.css" />
        <script type="text/javascript" src="ext/ajax.js"></script>
        <script type="text/javascript" src="ext/tlbMenu.js" />
        <script type="text/javascript">
            window.onload = initLeftMenu;
        </script>
        <script>
            function cookcb(d) {
            }
            function delC(id) {
                document.getElementById('c' + id).innerHTML="<img onclick='javascript: addC(\"" + id + "\")' src=graydot.gif>";
                sendCookAjax("action=del&delC=" + id, cookcb);
            }
            
            function addC(id) {
                document.getElementById('c' + id).innerHTML="<img onclick='javascript: delC(\"" + id + "\")' src=reddot.gif>";
                sendCookAjax("action=add&addC=" + id, cookcb);
            }
        </script>
    </head>
    
    <body onload="initLeftMenu()" style="left:0px;">
        <div id="mainContainer">
            
            <table>
                <tr>
                    <td colspan=2>
                        <div id="topBar">
                            
                            <%@ include file="header.jsp" %>
                            <br />
                            <a href="/blb/" target=_top>Back to Main Board</a>
                        </div>
                    </td>
                </tr>
                
                <tr>
                    <td valign="top">
                        
                        <div id="contentContainer" style="background-color:#FFFFFF">
                            <h1>Discussion Forum</h1>
                            
                            <table border=0 cellpadding=0 cellspacing=0 width=500>
                                
                                
                                <tr>
                                    <td colspan="3">
                                        <form action="fThreadList.jsp" name="searchForm" method="post">
                                            <input size=15 name="q" value="<%=request.getParameter("q") == null ? "" : request.getParameter("q").trim()%>" />
                                            <input type="submit" value="Search" class="btn" />
                                        </form>
                                        <br />
                                    </td>
                                </tr>
                                
                                <%
            ThreadDAO t = new ThreadDAO();
            List list = null;
            if (request.getParameter("q") != null && request.getParameter("q").trim().length() > 2) {
                list = t.searchThreads((session.getAttribute("poster") == null ? 0 : ((Poster) session.getAttribute("poster")).getPosterId()), 150, request.getParameter("q").trim());
            } else {
                list = t.getTopThreads((session.getAttribute("poster") == null ? 0 : ((Poster) session.getAttribute("poster")).getPosterId()), 150);
            }
            if (list != null) {
                for (Iterator it = list.iterator(); it.hasNext();) {
                    ThreadList thread = (ThreadList) it.next();

                    if (thread.getPower() != 0) {
                        thread.setTitle("[" + thread.getPower() + "] " + thread.getTitle());
                    }
                    thread.setTitle(new MonikerDAO().fixHTML(thread.getTitle()));

                    if (thread.getTitle() != null && thread.getTitle().length() > 35 && (thread.getTitle().indexOf(" ") == -1 || thread.getTitle().indexOf(" ") > 35)) {
                        thread.setTitle(thread.getTitle().substring(0, 35) + "<br>" + thread.getTitle().substring(35));
                    }

                                %>
                                <tr><td>
                                        <%= marks.containsKey(thread.getThreadId() + "")
                        ? "<span id='c" + thread.getThreadId() + "'><img onclick='javascript: delC(\"" + thread.getThreadId() + "\")' src=ext/reddot.gif></span>"
                        : "<span id='c" + thread.getThreadId() + "'><img onclick='javascript: addC(\"" + thread.getThreadId() + "\")' src=ext/graydot.gif></span>"%>  
                                <a target=viewer href='viewThread.jsp?threadId=<%=thread.getThreadId()%>&x=<%=thread.getThreadCount()%>'><%=thread.getTitle()%></a></td><td>&nbsp;&nbsp;&nbsp;<%=thread.getLastPostString()%></td><td>&nbsp;(<%=thread.getThreadCount()%>)</td></tr>
                                <%
                                    }
                                } else {
                                %><br>No results for search: <%=request.getParameter("q")%><%
            }
                                %>
                                
                                
                            </TABLE>
                        </div>
                    </td>
                </tr>
            </table>
            
            
        </div>
        <!-- Start of StatCounter Code -->
        <script type="text/javascript">
            var sc_project=2753481; 
            var sc_invisible=0; 
            var sc_partition=27; 
            var sc_security="fadeb289"; 
        </script>
        <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a class="statcounter" href="http://www.statcounter.com/"><img class="statcounter" src="http://c28.statcounter.com/2753481/0/fadeb289/0/" alt="blog stats" /></a></div></noscript>
        <!-- End of StatCounter Code -->
    </body>
</html>